// If your port is set to 80,
// use administrator privileges to execute the command line.
// For example, Mac: sudo npm run
const path = require('path');

function resolve(dir) {
	// 此处使用path.resolve 或path.join 可自行调整
	// path.resolve(__dirname, 'examples'),
	return path.join(__dirname, dir);

}

const port = 80; // dev port
const webpack = require('webpack');
process.env.NODE_ENV = 'development';
module.exports = {
	assetsDir: 'static',
	publicPath: '/',
	outputDir: './target/dist',
	lintOnSave: false,
	// lintOnSave: process.env.NODE_ENV === 'development',
	productionSourceMap: false,
	transpileDependencies: [/node_modules[/\\\\](element-ui|vuex|vue-router-tab|jsoneditor|vanilla-picker)[/\\\\]/],
	devServer: {
		// disableHostCheck: true,
		// host: '0.0.0.0',
		host: 'vue.roczhang.cn',
		port,
		open: true,
		overlay: {
			warnings: false,
			errors: true
		},
		proxy: {
			'/api/': {
				target: process.env.VUE_APP_SERVER_URL,
				ws: true,
				changeOrigin: true,
				pathRewrite: {
					'^/api/': '/'
				}
			}
		},
	},
	chainWebpack: config => {
		config.resolve.alias
			.set('@', resolve('src'))
			.set('views', resolve('src/views'))
			.set('assets', resolve('src/assets'))
			.set('components', resolve('src/components'))
			.set('base', resolve('baseConfig'))
			.set('public', resolve('public'));
			// config.entry.app = ['@babel/polyfill', './src/main.js'];
			// config.entry('main').add('babel-polyfill');
			// config.module
			// 	.rule('static')
			// 	.test(/\.js$/)
			// 	.use('babel-loader')
			// 	.loader('babel-loader')
			// 	.end();
	},
	configureWebpack: {
		// resolve: {
		// 		alias: {
		// 			'@assets': resolve('src/assets'),
		// 			'@': resolve('src')
		// 		}
		// 	},
		// extensions: ['.js', '.vue', 'json'],
		plugins: [
			new webpack.ProvidePlugin({
				jQuery: 'jquery',
				$: 'jquery'
			})
		]
	},
};
